<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: BasicModule Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00031.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a>  </div>
  <div class="headertitle">
<div class="title">BasicModule Class Reference</div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="BasicModule" --><!-- doxytag: inherits="INotifiable" -->
<p>Base class for all simple modules of a host that want to have access to the <a class="el" href="a00164.html">NotificationBoard</a> module.  
 <a href="a00031.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="a00320_source.html">BasicModule.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for BasicModule:</div>
<div class="dyncontent">
<div class="center"><img src="a00605.png" border="0" usemap="#BasicModule_inherit__map" alt="Inheritance graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for BasicModule:</div>
<div class="dyncontent">
<div class="center"><img src="a00606.png" border="0" usemap="#BasicModule_coll__map" alt="Collaboration graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>

<p><a href="a00607.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa05d2372f6004febdbcb02175f218369"></a><!-- doxytag: member="BasicModule::findHost" ref="aa05d2372f6004febdbcb02175f218369" args="(bool errorIfNotFound=true) const " -->
virtual cModule *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00031.html#aa05d2372f6004febdbcb02175f218369">findHost</a> (bool errorIfNotFound=true) const </td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Function to get a pointer to the host module. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00031.html#ad3cb64be134cf17fedc75bd04b698a8e">getLogName</a> (int)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Function to get the logging name of id.  <a href="#ad3cb64be134cf17fedc75bd04b698a8e"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00031.html#ae0497ccac7ad62630013847a8985dd4e">initialize</a> (int)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Basic initialization for all modules.  <a href="#ae0497ccac7ad62630013847a8985dd4e"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00031.html#a970d6ae46715ef49ca54b79efcf8df7a">numInitStages</a> () const </td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Divide initialization into two stages.  <a href="#a970d6ae46715ef49ca54b79efcf8df7a"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00031.html#a148b7c2d82dc4b7a551193a367591e04">logName</a> (void) const </td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Function to get the logging name of the host.  <a href="#a148b7c2d82dc4b7a551193a367591e04"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aaba53958696e211632fbf133f7ca0ca4"></a><!-- doxytag: member="BasicModule::receiveChangeNotification" ref="aaba53958696e211632fbf133f7ca0ca4" args="(int category, const cObject *details)" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00031.html#aaba53958696e211632fbf133f7ca0ca4">receiveChangeNotification</a> (int category, const cObject *details)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Called by the <a class="el" href="a00164.html">NotificationBoard</a> whenever a change of a category occurs to which we have subscribed. Redefined from <a class="el" href="a00102.html">INotifiable</a>. <br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a8236f7f9236aa45ff3921bb7918e8b16"></a><!-- doxytag: member="BasicModule::coreDebug" ref="a8236f7f9236aa45ff3921bb7918e8b16" args="" -->
bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00031.html#a8236f7f9236aa45ff3921bb7918e8b16">coreDebug</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Debug switch for the core modules. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a6ad967ecb9d1507f3efea5a11f89eae7"></a><!-- doxytag: member="BasicModule::debug" ref="a6ad967ecb9d1507f3efea5a11f89eae7" args="" -->
bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00031.html#a6ad967ecb9d1507f3efea5a11f89eae7">debug</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Debug switch for all other modules. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a6b20f2c5f3846ce757517c5b37db501b"></a><!-- doxytag: member="BasicModule::loggingName" ref="a6b20f2c5f3846ce757517c5b37db501b" args="" -->
std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00031.html#a6b20f2c5f3846ce757517c5b37db501b">loggingName</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Log name of the host module. <br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Base class for all simple modules of a host that want to have access to the <a class="el" href="a00164.html">NotificationBoard</a> module. </p>
<p>The basic module additionally provides a function <a class="el" href="a00031.html#aa05d2372f6004febdbcb02175f218369" title="Function to get a pointer to the host module.">findHost()</a> which returns a pointer to the host module.</p>
<p>There is no Define_Module() for this class because we use <a class="el" href="a00031.html" title="Base class for all simple modules of a host that want to have access to the NotificationBoard module...">BasicModule</a> only as a base class to derive all other module. There will never be a stand-alone <a class="el" href="a00031.html" title="Base class for all simple modules of a host that want to have access to the NotificationBoard module...">BasicModule</a> module (and that is why there is no Define_Module() and no .ned file for <a class="el" href="a00031.html" title="Base class for all simple modules of a host that want to have access to the NotificationBoard module...">BasicModule</a>).</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="a00164.html">NotificationBoard</a></dd></dl>
<dl class="author"><dt><b>Author:</b></dt><dd>Steffen Sroka </dd>
<dd>
Andreas Koepke </dd></dl>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="ad3cb64be134cf17fedc75bd04b698a8e"></a><!-- doxytag: member="BasicModule::getLogName" ref="ad3cb64be134cf17fedc75bd04b698a8e" args="(int)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const char * BasicModule::getLogName </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>id</em></td><td>)</td>
          <td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Function to get the logging name of id. </p>
<p>This function returns the logging name of the module with the specified id. It can be used for logging messages to simplify debugging in TKEnv.</p>
<p>Only supports ids from simple module derived from the <a class="el" href="a00031.html" title="Base class for all simple modules of a host that want to have access to the NotificationBoard module...">BasicModule</a> or the nic compound module id.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">id</td><td>Id of the module for the desired logging name </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>logging name of module id or NULL if not found </dd></dl>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="a00031.html#a148b7c2d82dc4b7a551193a367591e04" title="Function to get the logging name of the host.">logName</a> </dd></dl>

<p>References <a class="el" href="a00031.html#a148b7c2d82dc4b7a551193a367591e04">logName()</a>.</p>
<div class="fragment"><pre class="fragment">{
    <a class="code" href="a00031.html" title="Base class for all simple modules of a host that want to have access to the NotificationBoard module...">BasicModule</a> *mod;
    mod = (<a class="code" href="a00031.html" title="Base class for all simple modules of a host that want to have access to the NotificationBoard module...">BasicModule</a> *) simulation.getModule(<span class="keywordtype">id</span>);
    <span class="keywordflow">if</span> (mod-&gt;isSimple())
        <span class="keywordflow">return</span> mod-&gt;<a class="code" href="a00031.html#a148b7c2d82dc4b7a551193a367591e04" title="Function to get the logging name of the host.">logName</a>();
    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (mod-&gt;getSubmodule(<span class="stringliteral">&quot;snrEval&quot;</span>))
        <span class="keywordflow">return</span> ((<a class="code" href="a00031.html" title="Base class for all simple modules of a host that want to have access to the NotificationBoard module...">BasicModule</a> *) mod-&gt;getSubmodule(<span class="stringliteral">&quot;snrEval&quot;</span>))-&gt;<a class="code" href="a00031.html#a148b7c2d82dc4b7a551193a367591e04" title="Function to get the logging name of the host.">logName</a>();
    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (mod-&gt;getSubmodule(<span class="stringliteral">&quot;phy&quot;</span>))
        <span class="keywordflow">return</span> ((<a class="code" href="a00031.html" title="Base class for all simple modules of a host that want to have access to the NotificationBoard module...">BasicModule</a> *) mod-&gt;getSubmodule(<span class="stringliteral">&quot;phy&quot;</span>))-&gt;<a class="code" href="a00031.html#a148b7c2d82dc4b7a551193a367591e04" title="Function to get the logging name of the host.">logName</a>();
    <span class="keywordflow">else</span>
        <span class="keywordflow">return</span> NULL;
};
</pre></div>
</div>
</div>
<a class="anchor" id="ae0497ccac7ad62630013847a8985dd4e"></a><!-- doxytag: member="BasicModule::initialize" ref="ae0497ccac7ad62630013847a8985dd4e" args="(int)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void BasicModule::initialize </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>stage</em></td><td>)</td>
          <td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Basic initialization for all modules. </p>
<p>Subscription to <a class="el" href="a00164.html">NotificationBoard</a> should be in stage==0, and firing notifications in stage==1 or later.</p>
<p>NOTE: You have to call this in the <a class="el" href="a00031.html#ae0497ccac7ad62630013847a8985dd4e" title="Basic initialization for all modules.">initialize()</a> function of the inherited class! </p>

<p>Reimplemented in <a class="el" href="a00142.html#a9e116be526a0d4f1f4482728f32c237c">MoBANCoordinator</a>, <a class="el" href="a00145.html#a4c79fdde6758f5cb3b879d8a712911c9">MobilityBase</a>, <a class="el" href="a00143.html#a2838f6184efad9d12ec25e6d46494aea">MoBANLocal</a>, <a class="el" href="a00147.html#a42b5578a418c86489c79cb765f1ffd4f">MovingMobilityBase</a>, <a class="el" href="a00167.html#a17b0114ff0352fbbb0ef592feb874c74">Ns2MotionMobility</a>, <a class="el" href="a00220.html#a6f15f0b51441338a3e828135d598c1a5">TurtleMobility</a>, <a class="el" href="a00046.html#a6ab5b8976743a51b6d06dd98ce1b402e">CircleMobility</a>, <a class="el" href="a00139.html#a54edb0941c1fe0e902ef0b3723d73687">MassMobility</a>, <a class="el" href="a00187.html#a7042d73fe8ec8419352e5e0e8d188e28">RectangleMobility</a>, <a class="el" href="a00123.html#a0c7740d41d6a78d864ce6772af4fa664">LinearNodeDistributionMobility</a>, <a class="el" href="a00096.html#ab11b6af164abb0784b0e637bec8c81ee">GaussMarkovMobility</a>, <a class="el" href="a00124.html#a93df492d182199a12256c150f61da90b">LineSegmentsMobilityBase</a>, <a class="el" href="a00010.html#a6ac23c2be4355fc0b5fb60f5f59d5270">ANSimMobility</a>, <a class="el" href="a00062.html#a526493cba2a06a0c1df36bc1f190ac1c">ConstSpeedMobility</a>, <a class="el" href="a00204.html#a42d1cb48bbda91008d175b9dbcd998f8">StaticGridMobility</a>, <a class="el" href="a00216.html#a5dc11ca4b22d7c70f796bf59b4a6ce3d">TractorMobility</a>, <a class="el" href="a00038.html#aefa1902bb0eb0797092868ed523c1327">BonnMotionMobility</a>, <a class="el" href="a00122.html#a90721c1e167c816383c1f9a13ceb81cc">LinearMobility</a>, <a class="el" href="a00045.html#a58c485d8f5ec8acfd2b69570f956cd12">ChiangMobility</a>, and <a class="el" href="a00186.html#ae3269ca71d4aa02a51fc7933782737e0">RandomWPMobility</a>.</p>

<p>References <a class="el" href="a00031.html#a8236f7f9236aa45ff3921bb7918e8b16">coreDebug</a>, <a class="el" href="a00031.html#a6ad967ecb9d1507f3efea5a11f89eae7">debug</a>, <a class="el" href="a00031.html#aa05d2372f6004febdbcb02175f218369">findHost()</a>, and <a class="el" href="a00031.html#a6b20f2c5f3846ce757517c5b37db501b">loggingName</a>.</p>
<div class="fragment"><pre class="fragment">{
    cModule *host = <a class="code" href="a00031.html#aa05d2372f6004febdbcb02175f218369" title="Function to get a pointer to the host module.">findHost</a>(<span class="keyword">false</span>);

    <span class="keywordflow">if</span> (stage == 0)
    {

        <span class="keywordflow">if</span> (hasPar(<span class="stringliteral">&quot;coreDebug&quot;</span>))
            <a class="code" href="a00031.html#a8236f7f9236aa45ff3921bb7918e8b16" title="Debug switch for the core modules.">coreDebug</a> = par(<span class="stringliteral">&quot;coreDebug&quot;</span>).boolValue();
        <span class="keywordflow">else</span>
            <a class="code" href="a00031.html#a8236f7f9236aa45ff3921bb7918e8b16" title="Debug switch for the core modules.">coreDebug</a> = <span class="keyword">false</span>;
        <span class="keywordflow">if</span> (hasPar(<span class="stringliteral">&quot;debug&quot;</span>))
            <a class="code" href="a00031.html#a6ad967ecb9d1507f3efea5a11f89eae7" title="Debug switch for all other modules.">debug</a> = par(<span class="stringliteral">&quot;debug&quot;</span>).boolValue();
        <span class="keywordflow">else</span>
            <a class="code" href="a00031.html#a6ad967ecb9d1507f3efea5a11f89eae7" title="Debug switch for all other modules.">debug</a> = <span class="keyword">false</span>;

        <span class="keywordflow">if</span> (host) {
            <span class="comment">// get the logging name of the host</span>
            <span class="keywordflow">if</span> (host-&gt;hasPar(<span class="stringliteral">&quot;logName&quot;</span>))
                <a class="code" href="a00031.html#a6b20f2c5f3846ce757517c5b37db501b" title="Log name of the host module.">loggingName</a> = host-&gt;par(<span class="stringliteral">&quot;logName&quot;</span>).stringValue();
            <span class="keywordflow">else</span>
                <a class="code" href="a00031.html#a6b20f2c5f3846ce757517c5b37db501b" title="Log name of the host module.">loggingName</a> = host-&gt;getName();
            <span class="keywordtype">char</span> tmp[8];
            sprintf(&amp;tmp[0], <span class="stringliteral">&quot;[%d]&quot;</span>, host-&gt;getIndex());
            <a class="code" href="a00031.html#a6b20f2c5f3846ce757517c5b37db501b" title="Log name of the host module.">loggingName</a> += tmp;
        }
    }
}
</pre></div>
</div>
</div>
<a class="anchor" id="a148b7c2d82dc4b7a551193a367591e04"></a><!-- doxytag: member="BasicModule::logName" ref="a148b7c2d82dc4b7a551193a367591e04" args="(void) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const char* BasicModule::logName </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td> const<code> [inline, protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Function to get the logging name of the host. </p>
<p>The logging name is the ned module name of the host (unless the host ned variable loggingName is specified). It can be used for logging messages to simplify debugging in TKEnv. </p>

<p>Referenced by <a class="el" href="a00031.html#ad3cb64be134cf17fedc75bd04b698a8e">getLogName()</a>.</p>
<div class="fragment"><pre class="fragment">    {
      <span class="keywordflow">return</span> <a class="code" href="a00031.html#a6b20f2c5f3846ce757517c5b37db501b" title="Log name of the host module.">loggingName</a>.c_str();
    };
</pre></div>
</div>
</div>
<a class="anchor" id="a970d6ae46715ef49ca54b79efcf8df7a"></a><!-- doxytag: member="BasicModule::numInitStages" ref="a970d6ae46715ef49ca54b79efcf8df7a" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual int BasicModule::numInitStages </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const<code> [inline, protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Divide initialization into two stages. </p>
<p>In the first stage (stage==0), modules subscribe to notification categories at <a class="el" href="a00164.html">NotificationBoard</a>. The first notifications (e.g. about the initial values of some variables such as RadioState) should take place earliest in the second stage (stage==1), when everyone interested in them has already subscribed. </p>

<p>Reimplemented in <a class="el" href="a00145.html#ac86018a375bf83f14dc36bf222bfd5bd">MobilityBase</a>, and <a class="el" href="a00147.html#a86cf9ed4e4d9cf256d8f4ef1a1c34288">MovingMobilityBase</a>.</p>
<div class="fragment"><pre class="fragment">{<span class="keywordflow">return</span> 2;}
</pre></div>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>D:/Projects/MiXiM/extsrc/mixim/src/inet_stub/base/<a class="el" href="a00320_source.html">BasicModule.h</a></li>
<li>D:/Projects/MiXiM/extsrc/mixim/src/inet_stub/base/BasicModule.cc</li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00031.html">BasicModule</a>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:31 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
